/*
 * DTOAsteroide.cpp
 *
 *  Created on: Apr 1, 2012
 *      Author: gonzalo
 */

#include "DTOAsteroide.h"

DTOAsteroide::DTOAsteroide(DTOTipoAsteroide* tipo,int x,int y,int direccion,int velocidad)
:DTO(ASTEROIDE,SERVER_OWN){
	this->tipo = tipo;
	this->x = x;
	this->y = y;
	this->direccion = direccion;
	this->velocidad = velocidad;
}


DTOAsteroide::DTOAsteroide(std::string& aDeserealizar, std::string owner) :
		DTO(ASTEROIDE, owner) {
	deserializar(aDeserealizar, owner);
}

std::string DTOAsteroide::serializar(){
	std::stringstream retorno;

	retorno << UtilString::TOlenghtStringStringValue(x);
	retorno << UtilString::TOlenghtStringStringValue(y);
	retorno << UtilString::TOlenghtStringStringValue(direccion);
	retorno << UtilString::TOlenghtStringStringValue(velocidad);
	retorno << tipo->serializar();

	return retorno.str();
}
void DTOAsteroide::deserializar(std::string& string,std::string owner){
	x = UtilString::stringToInt(UtilString::FROMlenghtStringStringValue(string));
	y = UtilString::stringToInt(UtilString::FROMlenghtStringStringValue(string));
	direccion = UtilString::stringToInt(UtilString::FROMlenghtStringStringValue(string));
	velocidad = UtilString::stringToInt(UtilString::FROMlenghtStringStringValue(string));
	tipo = new DTOTipoAsteroide(string,owner);
}

